local Class = require('lua.lang.Class')
local LuaError = require('lua.vm.LuaError')

--- @class Varargs : Class
local Varargs = Class {}

--- @param i number
--- @return LuaValue
function Varargs:arg(i)
	error('Varargs:arg not implemented.')
end

--- @return number
function Varargs:narg()
	error('Varargs:narg not implemented.')
end

--- @return LuaValue
function Varargs:arg1()
	error('Varargs:arg1 not implemented.')
end

--- @return Varargs
function Varargs:evaluated()
	return self
end

--- @return boolean
function Varargs:isTailCall()
	return false
end

--- @param i number
--- @return number
function Varargs:type(i)
	return self:arg(i):type()
end

--- @param i number
--- @return boolean
function Varargs:isNil(i)
	return self:arg(i):isNil()
end

--- @param i number
--- @return boolean
function Varargs:isFunction(i)
	return self:arg(i):isFunction()
end

--- @param i number
--- @return boolean
function Varargs:isNumber(i)
	return self:arg(i):isNumber()
end

--- @param i number
--- @return boolean
function Varargs:isString(i)
	return self:arg(i):isString()
end

--- @param i number
--- @return boolean
function Varargs:isTable(i)
	return self:arg(i):isTable()
end

--- @return string
function Varargs:toLString()
	local sb = '('
	for i = 1, self:narg() do
		if i > 1 then
			sb = sb .. ', '
		end
		sb = sb .. self:arg(i):toLString()
	end
	return sb .. ')'
end

--- @param start number
--- @return Varargs
function Varargs:subArgs(start)
	error('Varargs:subArgs not implemented.')
end

--- @param iArg number
--- @param msg string
--- @return LuaValue
function Varargs:argError(iArg, msg)
	return LuaError:new('bad argument #' .. tostring(iArg) .. ': ' .. msg):throw()
end

return Varargs